﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using IHISCETeim.BLL;
using IHISCETeim.Library;
using IHISCETeim.Model;

namespace IHISCETeim.Web.MachineSys.MacModel
{
    public partial class OMailLineList : PageBase
    {
        protected override Permission[] PowerKey
        {
            get
            {
                return new Permission[] { Permission.查看, Permission.修改, Permission.新增, Permission.删除 };
            }
        }
        protected override string DWZRef
        {
            get
            {
                return "OMailLineList";
            }
        }
        #region 属性 (查询条件)


        protected string MachineType
        {
            get
            {
                return GetRequestValue<string>("MachineType", "");

            }
        }

        protected string SerialNumber
        {
            get
            {
                return GetRequestValue<string>("SerialNumber", "");
            }
        }
        protected string CreateDateFrom
        {
            get
            {
                return GetRequestValue<string>("CreateDateFrom", "");
            }
        }

        protected string CreateDateTo
        {
            get
            {
                return GetRequestValue<string>("CreateDateTo", "");
            }
        }



        protected override string orderField
        {
            get
            {
                return string.IsNullOrEmpty(base.orderField) ? "  CreateDate " : base.orderField;
            }
        }
        protected override string orderDirection
        {
            get
            {
                return string.IsNullOrEmpty(base.orderDirection) ? "Desc" : base.orderDirection;
            }
        }
        #endregion

        protected void Page_Load(object sender, EventArgs e)
        {
            DataBind();
            this.AddLog(Permission.查看, GetSQLWhere());
        }

        protected void DataBind()
        {

            this.rpMenu.DataSource = OMailLineController.GetOMailLinePagination(GetSQLWhere(), pageNum, numPerPage, SQLSort, ref TotalCount);
            this.rpMenu.DataBind();
        }

        protected string GetSQLWhere()
        {
            string wheresql = "";
            string sqlcommonFiled = "";
            if (!string.IsNullOrEmpty(MachineType))
            {
                sqlcommonFiled = QueryOperatorsEnumHelper.ConvertCommonOperator("MachineType", QueryOperatorsEnum.包含, MachineType);
                wheresql = sqlcommonFiled;
            }

            string DOWNSQL = "";
            if (!string.IsNullOrEmpty(SerialNumber))
            {
                DOWNSQL = QueryOperatorsEnumHelper.ConvertCommonOperator("SerialNumber", QueryOperatorsEnum.包含, SerialNumber);
                if (!string.IsNullOrEmpty(wheresql))
                {
                    wheresql += " and " + DOWNSQL;
                }
                else
                {
                    wheresql = DOWNSQL;
                }
            }
            if (!string.IsNullOrEmpty(CreateDateFrom))
            {
                DOWNSQL = QueryOperatorsEnumHelper.ConvertCommonOperator("CreateDate", QueryOperatorsEnum.范围, CreateDateFrom + "|" + CreateDateTo);
                if (!string.IsNullOrEmpty(wheresql))
                {
                    wheresql += " and " + DOWNSQL;
                }
                else
                {
                    wheresql = DOWNSQL;
                }
            }


            return wheresql;
        }
    }
}